using UnityEngine;
using UnityEngine.UI;

public class ValueBar : MonoBehaviour
{
	public RectTransform Bar;

	public RectTransform BarBG;

	public float Value = 50f;

	public float ValueMax = 100f;

	public Text ValueText;

	public string CustomText = string.Empty;

	private void Start()
	{
	}

	private void Update()
	{
		if (Bar != null && BarBG != null)
		{
			Vector2 sizeDelta = BarBG.sizeDelta;
			float num = sizeDelta.x / ValueMax * Value;
			RectTransform bar = Bar;
			float x = num;
			Vector2 sizeDelta2 = Bar.sizeDelta;
			bar.sizeDelta = new Vector2(x, sizeDelta2.y);
		}
		if ((bool)ValueText)
		{
			ValueText.text = Value.ToString();
			if (CustomText != string.Empty)
			{
				ValueText.text = CustomText;
			}
		}
	}
}
